package com.mastercard.auth

class Address {
	
	static auditable = true
	enum Indicator {Y,N}
	
	String postcode
	String country
	String addressLine1
	String addressLine2
	String addressLine3
	String addressType
	Indicator defaultInd
	
	static belongsTo = [user:User]
    static constraints = {
		addressType nullable:true
		postcode nullable:true
		country nullable:true
		addressLine1 nullable:true
		addressLine2 nullable:true
		addressLine3 nullable:true
		defaultInd blank:false
	}
	
	String toString(){
		return addressLine1 + ", " + addressLine2 + ", " + addressLine3 + " "	+ country + ", (" + postcode + ")"
	}
	
	def beforeInsert() {
		if(null == defaultInd){
			defaultInd = Indicator.N
		}
	}
	
	def beforeUpdate() {
		if(null == defaultInd){
			defaultInd = Indicator.N
		}
	}
}
